package org.hilo.boot;

import org.jretty.util.NestedRuntimeException;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

/**
 * 默认的启动配置
 * 
 * @author zollty
 * @since 2018-2-28
 */
@SpringBootApplication
@ComponentScan(basePackageClasses = BootstrapConfig.class)
abstract public class BootstrapConfig {
    
    private static byte[] lock = new byte[0];
    /**
     * 保持Main线程不退出，
     * 如果Main线程退出了，又没有其他非守护线程存在，则进程将自动结束。
     */
    public static void keepRunning() {
        synchronized(lock) {
            try {
                lock.wait();
            } catch (InterruptedException e) {
                throw new NestedRuntimeException(e);
            }
        }
    }
}
